home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 27 / CU Amiga Magazine's Super CD-ROM 27 (1998)(EMAP Images)(GB)[!][issue 1998-10].iso / CUCD / Programming / JForth / JTools / DevTools / showmem < prev    next >
Encoding:
Text File  |  1989-04-29  |  929 b   |  35 lines

  1. \ List out JForth memory allocations (via ALLOCBLOCK primitive)...
  2. \
  3. \ Mike Haas, 1988
  4. \
  5. \ mod: 29-apr-89 mdh moved 'SMBase @ base !' to end of word
  6.  
  7. anew Task-ShowMem
  8.  
  9. variable SMTotal   \ total bytes allocated counter
  10. variable SMBase    \ users original base
  11.  
  12. : SHOWMEM  ( -- )
  13.   >newline          \ move to next line, unless there
  14.   base @ SMBase !   \ save user's base for restoral
  15.   SMTotal off       \ initialize counter
  16.   FreeAtBye @ ?dup  \ any memory allocated at all?
  17.   IF
  18.      dup FreeCell 0   \ get how many allocations as DO-LOOP indices
  19.      DO
  20.         dup @ dup SizeMem  ( -- &FreeAtBye Mem size )
  21.         dup SMTotal +!
  22.         decimal 9 .r  ."  (decimal) bytes at location "
  23.         hex     9 .r  ."  (hex)"
  24.         SMBase @ base !  ?pause cr  cell+
  25.      LOOP
  26.      drop
  27.   THEN
  28.   SMTotal @ dup
  29.   IF
  30.      ascii -  56   emit-to-column cr
  31.   THEN
  32.   decimal 9 .r  ."  (decimal) bytes allocated" cr
  33.   SMBase @ base !
  34. ;
  35.